﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ELTE.SEM.Common
{
    public class CustomValidator
    {
        public bool PasswordStrengthCheck(string passwordToValidate, short minLength, short minNumberCount, short minSpecialCharacterCount)
        {
            bool result = true;
            //check for length
            if (passwordToValidate.Length < minLength)
            {
                result = false;
            }
            else
            {
                //check for number character count
                if (passwordToValidate.Count(c => Char.IsNumber(c)) < minNumberCount)
                {
                    result = false;
                }
                else
                {
                    //check for special character count
                    if (passwordToValidate.Count(c => !Char.IsLetter(c) && !Char.IsNumber(c)) < minSpecialCharacterCount)
                    {
                        result = false;
                    }
                }
            }
            return result;
        }
    }
}
